<%@page language="Java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="includes/head.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Add user</title>
</head>
<body>
	<f:view>
		<span id="whole-page-wrapper">
			<div id="wrapper" align="center">
			<%@include file="includes/header.jsp" %>
			<%@include file="includes/menu.jsp" %>	
					
				<div id="content">
					<div id="inner-content">
						<c:if test="${sessionScope.user.loggedUser.type == 'Admin' }">
							<div ><h:form> 
								<h3>Podaj następujące dane:</h3><br>
								<div class="leftAlignedForm">
									<h3>Typ użytkownika</h3>
									<fieldset>
										<h:selectOneMenu value="#{user.type}">
											<f:selectItem itemLabel="Administrator" itemValue="Admin" />
											<f:selectItem itemLabel="Standardowy" itemValue="User" />
										</h:selectOneMenu>
									</fieldset>
									<h3>Imię</h3>
									<fieldset>
										<h:inputText id="name" label="name" required="true" value="#{user.name}" />
										<h:message for="name" />
									</fieldset>
									<h3>Nazwisko</h3>
									<fieldset>
										<h:inputText id="surname" label="surname" required="true" value="#{user.surname}" />
										<h:message for="surname" />
									</fieldset>
									<h3>Adres</h3>
									<fieldset>
										<h:inputText id="address" label="address" required="true" value="#{user.address}" />
										<h:message for="address" />
									</fieldset>
									<h3>Login</h3>
									<fieldset>
										<h:inputText id="login" label="login" required="true" value="#{user.login}" onkeyup="javascript:checkLogin(this)" /> <div id="loginStatus"> Dostępność loginu: - </div>
										<h:message for="login" />
									</fieldset>
									<h3>Hasło</h3>
									<fieldset>
										<h:inputSecret id="password" required="true" value="#{user.password}" />
									</fieldset>
									<h3>Potwierdź hasło</h3>
									<fieldset>
										<h:inputSecret id="repeatpass" required="true" value="#{user.repeatPass}"/>
									</fieldset><br>
									<fieldset>
										<h:commandButton value="Zarejestruj" action="#{user.addUser}"/>
									</fieldset>
								</div>
							</h:form><br>							
						</c:if>
						<c:if test="${sessionScope.user.loggedUser.type != 'Admin' }">
							Nie masz uprawnień do korzystania z tej strony!
						</c:if>
					</div>
				</div>
				<%@include file="includes/footer.jsp" %>
			</div>
		</span>
	</f:view>
</body>
</html>